* Introduced $wgVerifyMimeTypeIE to allow disabling the MSIE 6/7 file type
detection heuristic on upload, which is more conservative than the checks
that were changed above.
+* $wgExternalDiffEngine — Setting this to a string value of 'wikidiff',
+ 'wikidiff2', or 'wikidiff3' will no longer work. This legacy behaviour was
+ deprecated in MediaWiki 1.27, 1.32, and 1.27, respectively.
* $wgSkipSkin — Setting this instead of $wgSkipSkins, deprecated in 1.23, is now
hard-deprecated.
* $wgLocalInterwiki — Setting this instead of $wgLocalInterwikis, deprecated in
}
/**
- * Process $wgExternalDiffEngine and get a sane, usable engine
+ * Process ExternalDiffEngine config and get a sane, usable engine
*
* @return bool|string 'wikidiff2', path to an executable, or false
* @internal For use by this class and TextSlotDiffRenderer only.
*/
public static function getEngine() {
- global $wgExternalDiffEngine;
- // We use the global here instead of Config because we write to the value,
- // and Config is not mutable.
- if ( $wgExternalDiffEngine == 'wikidiff' || $wgExternalDiffEngine == 'wikidiff3' ) {
- wfDeprecated( "\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.27' );
- $wgExternalDiffEngine = false;
- } elseif ( $wgExternalDiffEngine == 'wikidiff2' ) {
- wfDeprecated( "\$wgExternalDiffEngine = '{$wgExternalDiffEngine}'", '1.32' );
- $wgExternalDiffEngine = false;
- } elseif ( !is_string( $wgExternalDiffEngine ) && $wgExternalDiffEngine !== false ) {
- // And prevent people from shooting themselves in the foot...
- wfWarn( '$wgExternalDiffEngine is set to a non-string value, forcing it to false' );
- $wgExternalDiffEngine = false;
- }
-
- if ( is_string( $wgExternalDiffEngine ) && is_executable( $wgExternalDiffEngine ) ) {
- return $wgExternalDiffEngine;
- } elseif ( $wgExternalDiffEngine === false && function_exists( 'wikidiff2_do_diff' ) ) {
+ $externalDiffEngine = MediaWikiServices::getInstance()->getMainConfig()
+ ->get( 'ExternalDiffEngine' );
+
+ if ( $externalDiffEngine ) {
+ if ( is_string( $externalDiffEngine ) ) {
+ if ( is_executable( $externalDiffEngine ) ) {
+ return $externalDiffEngine;
+ }
+ wfDebug( 'ExternalDiffEngine config points to a non-executable, ignoring' );
+ } else {
+ wfWarn( 'ExternalDiffEngine config is set to a non-string value, ignoring' );
+ }
+ }
+
+ if ( function_exists( 'wikidiff2_do_diff' ) ) {
return 'wikidiff2';
- } else {
- // Native PHP
- return false;
}
+
+ // Native PHP
+ return false;
}
/**
protected static $repl = [];
- protected function setUp() {
- parent::setUp();
-
- // Set $wgExternalDiffEngine to something bogus to try to force use of
- // the PHP engine rather than wikidiff2.
- $this->setMwGlobals( [
- 'wgExternalDiffEngine' => '/dev/null',
- ] );
- }
-
protected function addPage( $page, $text, $model = CONTENT_MODEL_WIKITEXT ) {
$title = Title::newFromText( 'ApiComparePagesTest ' . $page );
$content = ContentHandler::makeContent( $text, $title, $model );
$slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
$slotDiffRenderer->addModules( $output );
}
-
- public function testGetExtraCacheKeys() {
- $differenceEngine = new CustomDifferenceEngine();
- $slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
- $extraCacheKeys = $slotDiffRenderer->getExtraCacheKeys();
- $this->assertSame( [ 'foo' ], $extraCacheKeys );
- }
-
}
$oldContent = ContentHandler::makeContent( ...$oldContentArgs );
$newContent = ContentHandler::makeContent( ...$newContentArgs );
- // Set $wgExternalDiffEngine to something bogus to try to force use of
- // the PHP engine rather than wikidiff2.
- $this->setMwGlobals( [
- 'wgExternalDiffEngine' => '/dev/null',
- ] );
-
$differenceEngine = new DifferenceEngine();
$diff = $differenceEngine->generateContentDiffBody( $oldContent, $newContent );
$this->assertSame( $expectedDiff, $this->getPlainDiff( $diff ) );
}
public function testGenerateTextDiffBody() {
- // Set $wgExternalDiffEngine to something bogus to try to force use of
- // the PHP engine rather than wikidiff2.
- $this->setMwGlobals( [
- 'wgExternalDiffEngine' => '/dev/null',
- ] );
-
$oldText = "aaa\nbbb\nccc";
$newText = "aaa\nxxx\nccc";
$expectedDiff = " aaa aaa\n-bbb+xxx\n ccc ccc";
}
public function testSetContent() {
- // Set $wgExternalDiffEngine to something bogus to try to force use of
- // the PHP engine rather than wikidiff2.
- $this->setMwGlobals( [
- 'wgExternalDiffEngine' => '/dev/null',
- ] );
-
$oldContent = ContentHandler::makeContent( 'xxx', null, CONTENT_MODEL_TEXT );
$newContent = ContentHandler::makeContent( 'yyy', null, CONTENT_MODEL_TEXT );
public function testGetDiffBody(
RevisionRecord $oldRevision = null, RevisionRecord $newRevision = null, $expectedDiff
) {
- // Set $wgExternalDiffEngine to something bogus to try to force use of
- // the PHP engine rather than wikidiff2.
- $this->setMwGlobals( [
- 'wgExternalDiffEngine' => '/dev/null',
- ] );
-
if ( $expectedDiff instanceof Exception ) {
$this->setExpectedException( get_class( $expectedDiff ), $expectedDiff->getMessage() );
}
--- /dev/null
+<?php
+
+/**
+ * @group small
+ */
+class DifferenceEngineSlotDiffRendererIntegrationTest extends \MediaWikiIntegrationTestCase {
+
+ /**
+ * @covers DifferenceEngineSlotDiffRenderer::getExtraCacheKeys
+ */
+ public function testGetExtraCacheKeys_noExternalDiffEngineConfigured() {
+ $this->setMwGlobals( [ 'wgExternalDiffEngine' => null ] );
+
+ $differenceEngine = new CustomDifferenceEngine();
+ $slotDiffRenderer = new DifferenceEngineSlotDiffRenderer( $differenceEngine );
+ $extraCacheKeys = $slotDiffRenderer->getExtraCacheKeys();
+ $this->assertSame( [ 'foo' ], $extraCacheKeys );
+ }
+}